package com.iting.xmldemo;

import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

/**
 * @author iting Nie
 * @version 1.1
 * @create 2021/12/19
 */
public class SpeachDemo implements BeanNameAware, InitializingBean, DisposableBean,SpeachDemoInterface {
	private String driverClass;
	private String jdbcUrl;
	private String user;
	private String password;
	private UserDao userDao;
	private String brand;
	private String price;
	private String description;
	private String beanName;

	@Override
	public void afterPropertiesSet() throws Exception {
		System.out.println("InitializingBean的afterPropertiesSet执行了");
		this.description = "您好，您当前拥有的优惠券是"+brand + "的"+price+"元抵用券";
	}

	@Override
	public void setBeanName(String name) {
		System.out.println("BeanNameAware回调接口的setBeanName方法执行了");
		beanName = name;
	}

	public void myInit(){
		System.out.println("<init-method>指定的初始化方法执行了");
	}

	public void myDestroy(){
		System.out.println("<destroy-method>属性指定的销毁方法执行了");
	}

	@Override
	public void destroy() throws Exception {
		System.out.println("DisposableBean接口的destroy方法");
	}

	@Override
	public void useSpeachDemo(){
		System.out.println("正在使用bean:调用了SpeachDemo的useSpeachDemo方法");
	}

	public void setDriverClass(String driverClass) {
		this.driverClass = driverClass;
	}

	public void setJdbcUrl(String jdbcUrl) {
		this.jdbcUrl = jdbcUrl;
	}

	public void setUser(String user) {
		this.user = user;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public UserDao getUserDao() {
		return userDao;
	}

	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}
	@Override
	public String toString() {
		return "PlaceHolderBean{" +
				"driverClass='" + driverClass + '\'' +
				", jdbcUrl='" + jdbcUrl + '\'' +
				", user='" + user + '\'' +
				", password='" + password + '\'' +
				'}';
	}

	public String getBrand() {
		return brand;
	}

	public void setBrand(String brand) {
		this.brand = brand;
	}

	public String getPrice() {
		return price;
	}

	public void setPrice(String price) {
		this.price = price;
	}
}